/*
 * PlaylistRandomAction.java
 *
 * Created on December 6, 2005, 12:24 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package com.bff.slimserver.musicjukebox.lib.actions;

import com.bff.bjj.utils.Resources;
import java.awt.event.ActionEvent;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.AbstractAction;
import javax.swing.Action;
import org.bff.slimserver.SlimPlaylist;
import org.bff.slimserver.exception.SlimException;

/**
 *
 * @author Bill Findeisen
 */
public class PlaylistShuffleSongAction extends AbstractAction {

    private SlimPlaylist playlist;

    /** Creates a new instance of PlaylistRandomAction */
    public PlaylistShuffleSongAction(SlimPlaylist playlist) {
        this.playlist = playlist;
        setName();
    }

    @Override
    public void actionPerformed(ActionEvent evt) {
        try {
            if (playlist.isShuffleItem()) {
                playlist.shuffleOff();
            } else {
                playlist.shuffleItems();
            }
            setName();
        } catch (SlimException ex) {
            Logger.getLogger(PlaylistShuffleSongAction.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void setName() {
        try {
            if (playlist.isShuffleItem()) {
                putValue(Action.NAME, Resources.getMessage(Resources.LABEL_KEY.ACTION_PLAYLIST_UNSHUFFLE_SONG_NAME));
                putValue(Action.SHORT_DESCRIPTION, Resources.getMessage(Resources.LABEL_KEY.ACTION_PLAYLIST_UNSHUFFLE_SONG_SHORT_DESC));
                //putValue(Action.SMALL_ICON, Resources.getIcon(Resources.ICON_KEY.ACTION_PLAYLIST_UNSHUFFLE_SONG));
            } else {
                putValue(Action.NAME, Resources.getMessage(Resources.LABEL_KEY.ACTION_PLAYLIST_SHUFFLE_SONG_NAME));
                putValue(Action.SHORT_DESCRIPTION, Resources.getMessage(Resources.LABEL_KEY.ACTION_PLAYLIST_SHUFFLE_SONG_SHORT_DESC));
                //putValue(Action.SMALL_ICON, Resources.getIcon(Resources.ICON_KEY.ACTION_PLAYLIST_SHUFFLE_SONG));
            }
        } catch (SlimException ex) {
            Logger.getLogger(PlaylistShuffleSongAction.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
